//
//  SelectCompleteTableViewCell.m
//  BiologyLibrary
//
//  Created by WYC on 2018/12/2.
//  Copyright © 2018 youxh. All rights reserved.
//

#import "SelectCompleteTableViewCell.h"

@implementation SelectCompleteTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    UIButton *btn1=[UIButton buttonWithType:UIButtonTypeCustom];
    btn1.frame=CGRectMake(50, 15, 70, 20);
    [btn1 setImageEdgeInsets:UIEdgeInsetsMake(0.0,0.0 ,0.0, 50)];
    [btn1 setTitleEdgeInsets:UIEdgeInsetsMake(0.0,-30.0 ,0.0, 0)];
    
    [btn1 setTitle:@"  完成" forState:UIControlStateNormal];
    [btn1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [btn1 setTitleColor:[UIColor colorWithRed:0.22 green:0.57 blue:0.91 alpha:1.0] forState:UIControlStateSelected];
    btn1.titleLabel.font=[UIFont systemFontOfSize:15];
    [btn1 setImage:[UIImage imageNamed:@"selectbtn"] forState:UIControlStateNormal];
    [btn1 setImage:[UIImage imageNamed:@"selectbtn_f"] forState:UIControlStateSelected];
    [btn1 addTarget:self action:@selector(yesclick) forControlEvents:UIControlEventTouchUpInside];

    [self.contentView addSubview:btn1];
    UIButton *btn2=[UIButton buttonWithType:UIButtonTypeCustom];
    btn2.frame=CGRectMake(50+110, 15, 80, 20);
    [btn2 setImageEdgeInsets:UIEdgeInsetsMake(0.0,0.0 ,0.0, 60)];
    [btn2 setTitleEdgeInsets:UIEdgeInsetsMake(0.0,-30.0 ,0.0, 0)];
    [btn2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [btn2 setTitleColor:[UIColor colorWithRed:0.22 green:0.57 blue:0.91 alpha:1.0] forState:UIControlStateSelected];
    [btn2 setTitle:@"  未完成" forState:UIControlStateNormal];
    btn2.titleLabel.font=[UIFont systemFontOfSize:15];
    [btn2 setImage:[UIImage imageNamed:@"selectbtn"] forState:UIControlStateNormal];
    [btn2 setImage:[UIImage imageNamed:@"selectbtn_f"] forState:UIControlStateSelected];
    [btn2 addTarget:self action:@selector(noclick) forControlEvents:UIControlEventTouchUpInside];

    [self.contentView addSubview:btn2];
    _btnyes=btn1;
    _btnno=btn2;
}

-(void)setOnfinish:(NSString *)onfinish
{
    _onfinish = onfinish;
    if ([onfinish isEqualToString:@"1"]) {
        _btnyes.selected=YES;
        _btnno.selected=NO;
        
    }else {
        _btnno.selected=YES;
        _btnyes.selected=NO;
        
    }
}
-(void)yesclick
{
    if ([self.onfinish isEqualToString:@"1"]) {
        return;
    }
    self.onfinish = @"1";
    if (self.yesBlock) {
        self.yesBlock();
    }
}

-(void)noclick
{
    if (![self.onfinish isEqualToString:@"1"]) {
        return;
    }
    self.onfinish = @"0";
    if (self.noBlock) {
        self.noBlock();
    }
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
